package com.zhongcw.test.spring.argument.resolver.controller;

import com.zhongcw.test.spring.argument.resolver.entity.CPU;
import com.zhongcw.test.spring.argument.resolver.entity.Computer;
import com.zhongcw.test.spring.argument.resolver.entity.User;
import com.zhongcw.test.spring.argument.resolver.util.PrintUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author ZCW
 * @createTime 2017/11/30
 * @lastUpdateTime 2017/11/30 ZCW
 */
@RestController
public class UserController {

    @RequestMapping("/")
    public Map<String ,Date> index(Date utilDate, java.sql.Date sqlDate){

        PrintUtil.printAll(utilDate,sqlDate);

        Map<String ,Date> dateMap = new HashMap<>();

        dateMap.put("utilDate",utilDate);
        dateMap.put("sqlDate",sqlDate);

        return dateMap;
    }

    @RequestMapping("/cpu")
    public String createCPU(CPU cpu){
        return cpu==null?"null":cpu.toString();
    }

    @RequestMapping("/computer")
    public String createComputer(Computer computer){
        return computer==null?"null":computer.toString();
    }

    @RequestMapping("/user")
    public String createUser(User user){
        return user==null?"null":user.toString();
    }

}
